<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Usuarios</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	{% load staticfiles %} <link rel="stylesheet" href="{% static "css/spacelab.css" %}">
	{% load staticfiles %} <link rel="stylesheet" href="{% static "css/responsive.css" %}">
	{% load staticfiles %} <link rel="stylesheet" href="{% static "css/misestilos.css" %}"> 
	{% load staticfiles %} <link rel="stylesheet" href="{% static "css/menu_jquery.css" %}">

    <!-- JS files -->
    {% load staticfiles %} <script type="text/javascript" src="{% static "js/jquery.js" %}"></script>
    {% load staticfiles %} <script type="text/javascript" src="{% static "js/bootstrap.js" %}"></script>
    {% load staticfiles %} <script type="text/javascript" src="{% static "js/menu_jquery.js" %}"></script>
        
</head>
<body>

	{% include "topmenu.html" %} <!-- Top menu -->

	<div class="container">
		<div class="row-fluid">
			
			{% include "sidebar.html" %} <!-- Side bar -->

			<div class="span9">
				{% if show_message_success %}
	                <div class="alert alert-success">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
						{{mensaje_exito|safe}}
	                </div>
	            {% endif %}
	            {% if show_message_error %}
	            	<div class="alert alert-error">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
						{{mensaje_error|safe}}                
	                </div>
	            {% endif %}
				<!-- Users -->
				<div class="page-header">
					<h1>User</h1>
					<a class="btn btn-primary" href="/plataforma/universidades/agregar_user">Agregar user &raquo </a>
				</div>

				{{lista | safe}}

			</div> <!-- /span -->

			<!-- Modal Eliminar-->
			<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				 <div class="modal-header">
				    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				    <h3 id="myModalLabel">Alert!</h3>
				 </div>
				 <div class="modal-body">
				    <p><b>¿Está seguro que desea eliminar este usuario?</b></p>
				 </div>
				 <div class="modal-footer">
				    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>
				    <a class="btn btn-primary" id="PopUp_Save">Eliminar</a>
				 </div>
			</div><!-- Modal Eliminar-->
			<!-- Modal Ver-->
			<div id="modalVer" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
				 <div class="modal-header">
				    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				    <h3 id="modalLabel"><b>Datos del Usuario</b></h3>
				 </div>
				 <div class="modal-body">
				    	<div class="control-group">
							<label for="nombre" class="control-label"><b>Username:</b></label>
							<div class="username"></div>
						</div> <!-- Username -->
						<div class="control-group">
							<label for="primernombre" class="control-label"><b>Nombre:</b></label>
							<div class="firstname"></div>
						</div> <!-- Firstname -->
						<div class="control-group">
							<label for="apellido" class="control-label"><b>Apellido:</b></label>
							<div class="lastname"></div>
						</div> <!-- Lastname -->
						<div class="control-group">
							<label for="iduniversidad" class="control-label"><b>Asociado a universidad:</b></label>
							<div class="universidad"></div>
						</div> <!-- asociado a universidad -->
						<div class="control-group">
							<label for="correo" class="control-label"><b>Email:</b></label>
							<div class="email"></div>
						</div> <!-- email -->
						<div class="control-group">
							<label for="activo" class="control-label"><b>Es activo:</b></label>
							<div class="is_active"></div>
						</div> <!-- is_Active -->
						<div class="control-group">
							<label for="staff" class="control-label"><b>Es staff:</b></label>
							<div class="is_staff"></div>
						</div> <!-- is_staff -->
						<div class="control-group">
							<label for="superuser" class="control-label"><b>Es superuser:</b></label>
							<div class="is_superuser"></div>
						</div> <!-- is_superuser -->
				 </div>
				 <div class="modal-footer">
				    <button class="btn" data-dismiss="modal" aria-hidden="true">Cerrar</button>
				 </div>
			</div><!-- Modal Ver-->
		</div> <!-- /row -->
		{% include "footer.html" %} <!-- Footer -->
	</div> <!-- /container -->

	<script>
	function eliminar(user_id){
		$('#myModal').modal('show');
		$("#PopUp_Save").attr("href", "/plataforma/universidades/admin_user/"+user_id+"");
	}
	//, email, firstname, lastname, is_staff, is_active, is_superuser){
	function verDatos(id_user) {
	    $.ajax({
	       type: "POST",
	       url: "/plataforma/universidades/ajax_user_modal/",
	       data: {'id_user': id_user},
	       cache: false,
	       success: function(returndata){
	      
	             $(".username").html(returndata.username);
	             $(".email").html(returndata.email);
	             $(".universidad").html(returndata.universidad);
	             if(returndata.firstname != "")
	             	$(".firstname").html(returndata.firstname);
	             else
	             	$(".firstname").html("--");

	             if(returndata.lastname != "")
	             	$(".lastname").html(returndata.lastname);
	             else
	             	$(".lastname").html("--");

	             if (returndata.is_staff)
	             	$(".is_staff").html("Sí");
	             else
	             	$(".is_staff").html("No");
	             
	             if (returndata.is_active)
	             	$(".is_active").html("Sí");
	             else
	             	$(".is_active").html("No");
	             
	             if (returndata.is_superuser)
	             	$(".is_superuser").html("Sí");
	             else
	             	$(".is_superuser").html("No");

	       }
	    });
	    $('#modalVer').modal('show');

	}

	</script>
	
</body>
</html>